C#中, int, float, double, struct等為value type,
而由class宣告的物件稱為reference type.
由struct宣告的物件, 比如地址(Address)、座標(Point), 都是各自指一組資料.
如果它們的欄位值異動, 也代表者個物件變動了.
而class宣告的物件, 像是學生(Student)物件, 有姓名、學號、地址、電話、年級.
即使它的欄位有變化, 該學生物件仍是指它自己.
以struct宣告座標(Point):
public struct Point
{
    public int X { get; set; }
    public int Y { get; set; }
}
public class Program
{
    public void Main(string[] args)
    {
        Point p1 = new Point();
        p1.X = 1;
        p1.Y = 2;
    }
}
從上面的程式碼來看, 問題在於
不可變(immutable)性, 是讓物件被建立後, 不能隨意更改其內部狀態.
因此, 在前面Point的宣告, 修改其constructor與property:
public struct Point
{
    public int X { get; }
    public int Y { get; }
    public Point(int x, int y) : this()
    {
        X = x;
        Y = y;
    }
    public Point Add(Point point)
    {
        return new Point(X + point.X, Y + point.Y);
    }
}
經過上面重構, 我們可以得到immutable的Point物件.
且我們還增加一個Add函數, 代表兩個Point的X與Y各自相加後產生新的Point物件, 維持immutable.